﻿<UserControl x:Class="WorkflowApplicationControls.DetailsControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Toolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit">
    <Grid Name="grdMain">
        <ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto">
            <StackPanel>
                <!--Workflow required parameters.-->
                <Border BorderBrush="#FFC8C8C8" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5" Margin="10,10,10,0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="25"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Grid.Row="0" CornerRadius="5,5,0,0">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                    <GradientStop Color="#FFE8E8E8" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="28"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Path=WorkflowName}" TextWrapping="Wrap" Margin="5,0,0,0" FontSize="13"/>
                                <Button Visibility="Collapsed" Style="{DynamicResource MonitorButton}" Content="Button" x:Name="btnResetReqParams" 
                                        AutomationProperties.AutomationId="btnResetReqParams" ToolTip="Reset Parameters" 
                                        ToolTipService.ShowOnDisabled="True" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1"
                                        Width="22" Height="22"/>
                                <!--Command="{Binding Path=ResetRequiredParams}"-->
                            </Grid>
                        </Border>
                        <StackPanel VerticalAlignment="Stretch" Grid.Row="1">
                            <!--Workflow required parameters list-->
                            <ScrollViewer Margin="5,5,2,5" MaxHeight="150" Name="PropertyPaneHost"
                                          AutomationProperties.AutomationId="PropertyPaneHost" VerticalScrollBarVisibility="Auto"/>
                        </StackPanel>
                    </Grid>
                </Border>
                
                <!--Job details-->
                <Border BorderBrush="#FFC8C8C8" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5" Margin="10,10,10,0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="25"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Grid.Row="0" CornerRadius="5,5,0,0">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                    <GradientStop Color="#FFE8E8E8" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="Job Details" TextWrapping="Wrap" Margin="5,0,0,0" FontSize="13"/>
                            </Grid>
                        </Border>
                        
                        <!--Make the height of this grid 120 if the last row comes back in.-->
                        <Grid HorizontalAlignment="Stretch" Margin="5,2,5,5" Grid.Row="1" Grid.RowSpan="1" Height="90">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="30"/>
                                
                                <!--Make this 30 when the provenance check box is implemented. -->
                                <RowDefinition Height="0"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="0.205*"/>
                                <ColumnDefinition Width="0.795*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="Job Name:" TextWrapping="Wrap" Grid.ColumnSpan="1" Grid.RowSpan="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0"/>
                            <TextBlock Text="Node:" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Row="1" Margin="0,0,5,0"/>
                            <ComboBox IsSynchronizedWithCurrentItem="True" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="1" Grid.Column="1" Width="200"
                                      SelectedItem="{Binding Path=SelectedMachine}" ItemsSource="{Binding Path=NodeList}" ItemTemplate="{StaticResource ComboboxTemplate}"
                                      Name="cmbBoxNodes" AutomationProperties.AutomationId="cmbBoxNodes"/>
                            <TextBox HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Path=JobName}" TextWrapping="Wrap" Grid.Column="1" Width="200"
                                     Name="txtBxJobName" AutomationProperties.AutomationId="txtBxJobName" MaxLength="75" MaxLines="1"/>
                            <TextBlock Text="Run By:" TextWrapping="Wrap" HorizontalAlignment="Right" d:LayoutOverrides="Height" Grid.Row="2" VerticalAlignment="Center" Margin="0,0,5,0"/>
                            <ComboBox IsSynchronizedWithCurrentItem="True" d:LayoutOverrides="Height" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left"
                                      VerticalAlignment="Center" Width="200" SelectedItem="{Binding Path=SelectedUser}" ItemsSource="{Binding Path=UserList}"
                                       ItemTemplate="{StaticResource ComboboxTemplate}" Name="cmbBoxUsers" AutomationProperties.AutomationId="cmbBoxUsers"/>
                            <CheckBox Name="chkBoxEnableProvenance" AutomationProperties.AutomationId="chkBoxEnableProvenance" 
                                      HorizontalAlignment="Left" Content="Enable Provenance" d:LayoutOverrides="Height" Grid.Column="1" 
                                      Grid.Row="3" VerticalAlignment="Center" Visibility="Collapsed"/>
                        </Grid>
                    </Grid>
                </Border>
                
                <!--Additional parameters-->
                <Expander FontSize="12" Style="{DynamicResource ExpanderStyleadditionalPara}" Name="addParamsExpander"
                          AutomationProperties.AutomationId="addParamsExpander" Header="Additional Parameters" Margin="10,10,10,10">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Border BorderBrush="#FFC8C8C8" BorderThickness="1,0,1,1" CornerRadius="0,0,5,5" Grid.RowSpan="1" Margin="0,0,0,0">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="30"/>
                                </Grid.RowDefinitions>
                                <Toolkit:DataGrid Margin="5,5,2,5" Grid.RowSpan="1" x:Name="dataGrid" CanUserResizeColumns="False" 
                                                  CanUserResizeRows="False" CanUserDeleteRows="False"  CanUserAddRows="False" 
                                                  AutoGenerateColumns="False" ItemsSource="{Binding Path=AdditionalParameters}" 
                                                  HorizontalGridLinesBrush="LightGray" VerticalGridLinesBrush="LightGray" SelectionMode="Single"
                                                  MaxHeight="100" MinHeight="100">
                                    <Toolkit:DataGrid.Columns>
                                        <Toolkit:DataGridTextColumn Width="170" Binding="{Binding Path=Domain}" Header="Domain"/>
                                        <Toolkit:DataGridTextColumn Width="180" Binding="{Binding Path=Parameter}" Header="Parameter Name"/>
                                        <Toolkit:DataGridTextColumn Width="180" Binding="{Binding Path=ParameterValue}" Header="Parameter Value"/>
                                    </Toolkit:DataGrid.Columns>
                                </Toolkit:DataGrid>
                                <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" CornerRadius="0,0,5,5" Grid.Row="1" BorderThickness="0,1,0,0" BorderBrush="#FFE4E4E4">
                                    <Border.Background>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                            <GradientStop Color="#FFEAEAEA" Offset="0.991"/>
                                        </LinearGradientBrush>
                                    </Border.Background>
                                    <StackPanel VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Right">
                                        <Button Content="Delete" Width="60" Name="btnDelete" AutomationProperties.AutomationId="btnDelete" Margin="0,0,5,0" Command="{Binding Path=DeleteAdditionalParameterCommand}" CommandParameter="{Binding ElementName=dataGrid, Path=SelectedItem}"/>
                                        <Button Content="Add" Width="60" Name="btnAdd" AutomationProperties.AutomationId="btnAdd" Command="{Binding Path=AddAdditionalParameterCommand}"/>
                                    </StackPanel>
                                </Border>
                            </Grid>
                        </Border>
                    </Grid>
                </Expander>
                
                <!--Notes-->
                <Border BorderBrush="#FFC8C8C8" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5" Margin="10,10,10,10">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="25"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Grid.Row="0" CornerRadius="5,5,0,0">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFFFFFFF" Offset="0"/>
                                    <GradientStop Color="#FFE8E8E8" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Text="Notes" TextWrapping="Wrap" Margin="5,0,0,0" FontSize="13"/>
                            </Grid>
                        </Border>
                        <StackPanel HorizontalAlignment="Stretch" Margin="5,2,5,5" Grid.Row="1" Grid.RowSpan="1">
                            <TextBox Text="{Binding Path=JobNotes}" Name="jobNotes" AutomationProperties.AutomationId="jobNotes" MaxLines="4" 
                                     MaxLength="300" TextWrapping="Wrap" ScrollViewer.CanContentScroll="True" VerticalScrollBarVisibility="Auto" 
                                     Margin="0,2,5,2" Height="60"/>
                        </StackPanel>
                    </Grid>
                </Border>
            </StackPanel>
        </ScrollViewer>
    </Grid>
</UserControl>
